<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.${moduleName}.mapper.${ClassName}Mapper">

    <sql id="select${ClassName}VO">
        select
        <#list fieldList as field>
        ${field.fieldName}<#if field?has_next>,</#if>
        </#list>
        from ${tableName}
    </sql>

    <select id="selectPageList" parameterType="${package}.${moduleName}.query.${ClassName}Query"
            resultType="${package}.${moduleName}.vo.${ClassName}VO">
        <include refid="select${ClassName}VO"/>
        <where>
            <#list queryList as field>
                <#if field.queryType == '='>
                    <if test="query.${field.attrName}!=null<#if field.attrType=='String'> and query.${field.attrName}!=''</#if>">
                        and ${field.fieldName} = <#noparse>#{query.</#noparse>${field.attrName}}
                    </if>
                <#elseif field.queryType == 'like'>
                     <if test="query.${field.attrName}!=null<#if field.attrType=='String'> and query.${field.attrName}!=''</#if>">
                        and ${field.fieldName} like concat('%',<#noparse>#{query.</#noparse>${field.attrName}},'%')
                    </if>
                <#elseif field.queryType == '>'>
                    <if test="query.${field.attrName}!=null<#if field.attrType=='String'> and query.${field.attrName}!=''</#if>">
                        and ${field.fieldName} > <#noparse>#{query.</#noparse>${field.attrName}}
                    </if>
                <#elseif field.queryType == '>='>
                    <if test="query.${field.attrName}!=null<#if field.attrType=='String'> and query.${field.attrName}!=''</#if>">
                        and ${field.fieldName} >= <#noparse>#{query.</#noparse>${field.attrName}}
                    </if>
                <#elseif field.queryType == '<'>
                    <if test="query.${field.attrName}!=null<#if field.attrType=='String'> and query.${field.attrName}!=''</#if>">
                        and ${field.fieldName} <![CDATA[<]]> <#noparse>#{query.</#noparse>${field.attrName}}
                    </if>
                <#elseif field.queryType == '<='>
                    <if test="query.${field.attrName}!=null<#if field.attrType=='String'> and query.${field.attrName}!=''</#if>">
                        and ${field.fieldName} <![CDATA[<=]]> <#noparse>#{query.</#noparse>${field.attrName}}
                    </if>
                </#if>
            </#list>
        </where>
        order by create_time desc
    </select>

    <select id="selectDetail" resultType="${package}.${moduleName}.vo.${ClassName}VO">
        <include refid="select${ClassName}VO"/>
        <#noparse>where id = #{id}</#noparse>
    </select>
</mapper>